﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VideoClassLibrary.BusinessLogicLayer;
using System.Data;
using System.Web.UI.HtmlControls;
using VideoClassLibrary.Model;

public partial class CourseListManagement_SearchTeacherList : AdminUserBase
{
    public string[] IdListArray = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            bindPageData();
        }

    }
   /// <summary>
    /// 模糊查询
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        TeacherModule tm = new TeacherModule();
        int schoolId = this.CurrentUser.SchoolID;
        string teacherName = this.txtTeacherName.Text.ToString();
        List<V_teacher> list = tm.GetAllteacherByNameAndId(teacherName,schoolId);

        repTeacherList.DataSource = this.getPage(list); ;
        repTeacherList.DataBind();
    }
    protected void pager_PageChanged(object sender, EventArgs e)
    {
        bindPageData();
    }

    private void bindPageData()
    {
        int schoolId = this.CurrentUser.SchoolID;
        TeacherModule tm = new TeacherModule();
        DataSet ds = tm.GetTeacherByALL(schoolId);
        repTeacherList.DataSource = this.getPage(ds);
        repTeacherList.DataBind();
    }
    public PagedDataSource getPage(List<V_teacher> ls)
    {
        this.pager.RecordCount = ls.Count;
        PagedDataSource pds = new PagedDataSource();
        pds.DataSource = ls;
        pds.AllowPaging = true;
        pds.CurrentPageIndex = pager.CurrentPageIndex - 1;
        pds.PageSize = pager.PageSize;
        return pds;
    }

    public PagedDataSource getPage(DataSet ds)
    {
        this.pager.RecordCount = ds.Tables[0].Rows.Count;
        PagedDataSource pds = new PagedDataSource();
        pds.DataSource = ds.Tables[0].DefaultView;
        pds.AllowPaging = true;
        pds.CurrentPageIndex = pager.CurrentPageIndex - 1;
        pds.PageSize = pager.PageSize;
        return pds;
    }
}
